package com.example.learn.controller;

import com.example.learn.entity.DebtStatistics;

import com.example.learn.entity.User;
import com.example.learn.service.DebtstatisticalService;

import com.example.learn.token.CurrentUser;
import com.example.learn.token.UserLoginToken;
import com.example.learn.utile.Response.BaseResponse;
import com.example.learn.utile.Response.ObjectRestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/debtStatistics")
public class DebtStatisticalController {
    @Autowired
    DebtstatisticalService debtstatisticalService;

    @UserLoginToken
    @RequestMapping(value = "getdebtStatistics",method = RequestMethod.GET)
    public BaseResponse getDebtstatistical(@RequestParam Boolean isfamily, @CurrentUser User user){
        List<DebtStatistics> incomeList=      debtstatisticalService.getDebtstatistical(isfamily,user);
        return new ObjectRestResponse().data(incomeList);
    }

    @UserLoginToken
    @RequestMapping(value = "adddebtStatistics",method = RequestMethod.POST)
    public BaseResponse addDebtstatistical(@RequestBody DebtStatistics Debtstatistical , @CurrentUser User user){
        String incomeStr=      debtstatisticalService.addDebtstatistical(Debtstatistical,user);
        return new ObjectRestResponse().data(incomeStr);
    }

    @RequestMapping(value = "deletedebtStatistics",method = RequestMethod.POST)
    public BaseResponse deleteDebtstatistical(String id){
        String incomeStr=      debtstatisticalService.deleteDebtstatistical(id);
        return new ObjectRestResponse().data(incomeStr);
    }
}
